print("loading config.js ....");
// base
defineClass('com.jl.js.core.ByteArray');
defineClass('com.jl.js.core.JSAssert');
defineClass('com.jl.js.core.JSMemoryFile');
defineClass('com.jl.js.core.JSFile');
defineClass('com.jl.js.core.JSArrayList');
defineClass('com.jl.js.core.JSHashMap');
defineClass('com.jl.js.core.JSHashSet');
defineClass('com.jl.js.core.JSUtil');
defineClass('com.jl.js.core.JSHexUtil');
defineClass('com.jl.js.core.JSCalculator');
// card terminal
defineClass('com.jl.card.CardJSProxy');
defineClass('com.jl.card.TerminalSystem');
// card file and card file system
defineClass('com.jl.card.file.CardFile');
defineClass('com.jl.card.filesystem.JSFileSystemProxy');
defineClass('com.jl.card.cmd.CardCommand');
// applet
defineClass('com.jl.applet.ISOAppletJSProxy');
// STK
defineClass('com.jl.card.stk.STKJSProxy');
// global platform
defineClass('com.jl.card.gp.GlobalPlatform');
defineClass('com.jl.card.gp.GPKey');
defineClass('com.jl.card.gp.GPTool');
// command parser
defineClass('com.jl.card.parse.ATR');
defineClass('com.jl.card.parse.Parser');
// short message
defineClass('com.jl.sms.factory.ShortMessage');
defineClass('com.jl.sms.userdata.UserDataParam');
// security
defineClass('com.jl.security.Crypto');
/**
 * print with new line
 */
function println(/* ... */) {
	for ( var i = 0; i < arguments.length; ++i) {
		print(arguments[i]);
	}
	print('\n');
}
/**
 * Minimal assert() function
 */
function assert(/* ... */) {
	for ( var i = 0; i < arguments.length; i++) {
		Assert.isTrue(arguments[i]);
	}
}
/**
 * just use in console
 * @returns
 */
function r() {
	var res = card.reset(false);// reset cold
	return new ATR(res);
}
/**
 * just use in console
 * @param cmd
 * @returns
 */
function a(cmd) {
	var res = auto(cmd);
	if (res === null || !res || typeof res == 'undefine') {
		return "Error! no return data";
	}
	var par = new Parser(cmd, res);
	return par;
}
function send(cmd, expData, expSW) {
	card.plainAPDU(cmd);
	var _sw = HexUtil.toHex(lastSW(), 2);
	var _data = lastData().toString();
	if ((typeof expData) == "ByteArray") {
		expData = expData.toString();
	}
	if ((typeof expSW) == "number") {
		expSW = HexUtil.toHex(expSW, 2);
	}
	Assert.compareHex(expSW, _sw);
	Assert.compareHex(expData, _data);
}
function apdu(cmd, expData, expSW) {
	if (typeof expData != "undefined" && typeof expSW != "undefined") {
		if (typeof expData == "undefined") {
			expData = "";
		}
		if (typeof expSW == "undefined") {
			expSW = "";
		}
		send(cmd, expData, expSW);
	} else {
		return card.plainAPDU(cmd);
	}
}
function auto(cmd, expData, expSW) {
	if (typeof expData != "undefined" && typeof expSW != "undefined") {
		if (typeof expData == "undefined") {
			expData = "";
		}
		if (typeof expSW == "undefined") {
			expSW = "";
		}
		send(cmd, expData, expSW);
	} else {
		return card.autoAPDU(cmd);
	}
}
function setProvider(param) {
	card.setProvider(param);
	card.reconnect();
}
function rem(str) {
	str += '';
	var str_array = str.split('\n');
	for ( var i = 0; i < str_array.length; i++) {
		if (str_array[i] == "")
			continue;
		card.getTracer().tracerString('REM ' + str_array[i] + '\n');
	}
}
function lastSW() {
	return card.sw();//Number
}
function lastData() {
	var _data = card.data();
	if (_data == null) {
		return new ByteArray("");
	}
	return _data;//ByteArray
}
// load js file
load('CARD_LIB/UserObject.js');
